package com.synnex.mobile.servier.core.resource.service.impl;

import com.synnex.mobile.generic.core.util.ObjectUtil;
import com.synnex.mobile.servier.core.contact.bo.ContactBo;
import com.synnex.mobile.servier.core.contact.dao.ContactDao;
import com.synnex.mobile.servier.core.contact.dto.Contact;
import com.synnex.mobile.servier.core.resource.dao.ResourceDao;
import com.synnex.mobile.servier.core.resource.dto.Resource;
import com.synnex.mobile.servier.core.resource.service.ResourceService;
import com.synnex.mobile.servier.core.service.impl.AbstractServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-8-12
 * Time: 下午8:40
 * To change this template use File | Settings | File Templates.
 */
@Transactional
public class ResourceServiceImpl extends AbstractServiceImpl implements ResourceService {

    private ResourceDao resourceDao;

    public void setResourceDao(ResourceDao resourceDao) {
        this.resourceDao = resourceDao;
    }


    public List<Resource> ListResource(String key) {
        List<Resource> recordList = resourceDao.ListResource(key);
        return recordList;
    }

    public void addResource(Resource resource) {
//        Resource resource = ObjectUtil.copyProperties(contactBo, Contact.class);
        resource.setEntryDate(new Date());

        resourceDao.addResource(resource);
    }

    public void editResource(Resource resource) {
//        Contact record = ObjectUtil.copyProperties(recordBo, Contact.class);
        resource.setUpdateDate(new Date());

        resourceDao.editResource(resource);
    }

    public Resource getResourceById(Integer id) {

        Resource resource = resourceDao.getResourceById(id);
        return  resource;
    }

    public void deleteResourceById(Integer id) {
        resourceDao.  deleteResourceById(id);
    }
}
